clear all
set maxvar 5000
*ssc install estout, replace
*cd "1_Data/"
cd "/Users/tg2778/Dropbox/0_Reviews_RnRs/072022_JOP_Roads/v3_JOP/Replication - Roads"
log using "4_Log/7_PMGSY.log"

use "1_Data/pmgsycensuscombined2.dta", clear

egen statedistrict = group (pc01_state_id pc01_district_id )

**generate population variables
gen percentscstpop = (pc01_vd_st_p+ pc01_vd_sc_p)*100/pc01_vd_t_p
gen scstpop = pc01_vd_st_p+ pc01_vd_sc_p

*ppopulation between >=500 & <1000
gen pop5001k = 0
replace pop5001k = 1 if pc01_vd_t_p>=500 & pc01_vd_t_p<1000 & pc01_vd_t_p!=.

*ppopulation between >=1000
gen pop1k = 0
replace pop1k = 1 if  pc01_vd_t_p>=1000 & pc01_vd_t_p!=.

gen popvar = 0 if pc01_vd_t_p<=100 & pc01_vd_t_p!=.
replace popvar = 1 if pc01_vd_t_p>100 & pc01_vd_t_p<=250 & pc01_vd_t_p!=.
replace popvar = 2 if pc01_vd_t_p>250 & pc01_vd_t_p<500 & pc01_vd_t_p!=.
replace popvar = 3 if pc01_vd_t_p>=500 & pc01_vd_t_p<1000 & pc01_vd_t_p!=.
replace popvar = 4 if pc01_vd_t_p>=1000 & pc01_vd_t_p!=.

label define poplabel 0 "pop<=100" 1 "100<pop<=250" 2 "250<pop<500" 3 "500=<pop<1000" 4 "pop>=1000"
label values popvar poplabel

*****************************************************************
**ROAD VARIABLES
**pmgsy road (includes all projects)
replace pmgsyroad=0 if pmgsyroad==. 

**only new roads
gen pmgsynewroad = 0
replace pmgsynewroad = 1 if imsupgradeconnect ==1

**road in 2001 - is there road in baseline villages in 2001?
gen pavedroad2001 = pc01_vd_app_pr

*****************************************************************
**OTHER CENSUS VARIABLES THAT ARE USEFUL TO COMPARE 2001 AND 2011
****ELECTRICITY*****
*pc01_vd_power_supl
gen powerany2001 = 0 if pc01_vd_power_supl==0
replace powerany2001 = 1 if pc01_vd_power_supl==1

*pc11_vd_power_dom
gen powerdom2011 = 0 if power_domes_status_2011==0 
replace powerdom2011 = 1 if power_domes_status_2011==1
*****************
*primary health centre 

*2001
gen phc2001 = 0 if  pc01_vd_ph_cntr==0 & pc01_vd_ph_cntr!=.
replace phc2001 = 1 if  pc01_vd_ph_cntr>0 & pc01_vd_ph_cntr!=.

*2011
gen phc2011 = 0 if  phc_num_2011==0 & phc_num_2011!=.
replace phc2011 = 1 if  phc_num_2011>0 & phc_num_2011!=.

*****************
*post 
*2001
gen postoffice2001 = 0 if  pc01_vd_post_off==0 & pc01_vd_post_off!=.
replace postoffice2001 = 1 if  pc01_vd_post_off>0 & pc01_vd_post_off!=.

*2011
gen postoffice2011 = 0 if po_status_2011==0
replace postoffice2011 = 1 if po_status_2011==1

*****************
**primaryschool
*2001
gen pschool2001 = 0 if  pc01_vd_p_sch==0 & pc01_vd_p_sch!=.
replace pschool2001 = 1 if  pc01_vd_p_sch>0 & pc01_vd_p_sch!=.

*2011
*in 2011 census primary nd private is separaate pc11_vd_p_sch_gov_status pc11_vd_p_sch_priv_status
gen pschool2011 = 0 if pvt_p_num_2011==0 & govt_p_num_2011==0
replace pschool2011 = 1 if (pvt_p_num_2011>0 | govt_p_num_2011>0) & pvt_p_num_2011!=. & govt_p_num_2011!=.

*****************
**secondary school 
*2001
gen sschool2001 = 0 if  pc01_vd_s_sch==0 & pc01_vd_s_sch!=.
replace sschool2001 = 1 if  pc01_vd_s_sch>0 & pc01_vd_s_sch!=.

*2011
*pc11_vd_s_sch_gov_status pc11_vd_s_sch_priv_status
gen sschool2011 = 0 if pvt_s_num_2011==0 & govt_s_num_2011==0
replace sschool2011 = 1 if (pvt_s_num_2011>0 | govt_s_num_2011>0) & pvt_s_num_2011!=. & govt_s_num_2011!=.

*****************
**senior secondary school 
*2001
gen ssschool2001 = 0 if  pc01_vd_s_s_sch==0 & pc01_vd_s_s_sch!=.
replace ssschool2001 = 1 if  pc01_vd_s_s_sch>0 & pc01_vd_s_s_sch!=.

*2011
*pc11_vd_s_s_sch_gov_status pc11_vd_s_s_sch_priv_status
gen ssschool2011 = 0 if pvt_ss_num_2011==0 & govt_ss_num_2011==0
replace ssschool2011 = 1 if (pvt_ss_num_2011>0 | govt_ss_num_2011>0) & pvt_ss_num_2011!=. & govt_ss_num_2011!=.
*****************

**bank
*2001
gen bank2001 = 0 if pc01_vd_bank_fac==0
replace bank2001 = 1 if pc01_vd_bank_fac==1
gen commbank2001 = 0 if pc01_vd_comm_bank==0

*2011 (only commercial bank in 2011, not general bank variable)
replace commbank2001=1 if pc01_vd_comm_bank>0 & pc01_vd_comm_bank!=.
gen commbank2011 =  cb_status_2011

gen bus2011 = 0 if pvt_bus_status_2011==0 & pub_bus_status_2011==0
replace bus2011 = 1 if pvt_bus_status_2011==1| pub_bus_status_2011==1



quietly: areg pc11r_hl_light_source_elec i.popvar pc01_vd_t_p percentscstpop pschool2001 sschool2001 ssschool2001 pc01_vd_dist_town i.pc01_vd_tap commbank2001 phc2001 pc01_vd_p_t_fac pc01_vd_comm_fac if statedummy2==1 & powerany2001==0, absorb(statedistrict) cluster(pcmod01_state)
quietly: estimates store a_m1, title(OLS)

quietly: areg pc11r_hl_latrine_oth_open i.popvar pc01_vd_t_p percentscstpop pschool2001 sschool2001 ssschool2001 pc01_vd_dist_town i.pc01_vd_tap commbank2001 phc2001 pc01_vd_p_t_fac pc01_vd_comm_fac if statedummy2==1, absorb(statedistrict) cluster(pcmod01_state)
quietly: estimates store a_m2, title(OLS)

quietly: areg pmgsyroad i.popvar pc01_vd_t_p percentscstpop pschool2001 sschool2001 ssschool2001 pc01_vd_dist_town i.pc01_vd_tap commbank2001 phc2001 pc01_vd_p_t_fac pc01_vd_comm_fac if statedummy2==1, absorb(statedistrict) cluster(pcmod01_state)
quietly: estimates store a_m3, title(OLS)


*******************************************


quietly: areg pschool2011 pmgsyroad pop5001k pop1k pschool2001 if statedummy2==1, absorb(statedistrict) cluster(pcmod01_state)
quietly: estimates store b_m1, title(OLS)
quietly estadd local fe "Yes"
quietly estadd scalar rsqadj = e(r2_a)
quietly estadd scalar Nobs = e(N)
quietly estadd ysumm, me

quietly: areg sschool2011 pmgsyroad pop5001k pop1k sschool2001 if statedummy2==1, absorb(statedistrict) cluster(pcmod01_state)
quietly: estimates store b_m2, title(OLS)
quietly estadd local fe "Yes"
quietly estadd scalar rsqadj = e(r2_a)
quietly estadd scalar Nobs = e(N)
quietly estadd ysumm, me

quietly: areg ssschool2011 pmgsyroad pop5001k pop1k ssschool2001 if statedummy2==1, absorb(statedistrict) cluster(pcmod01_state)
quietly: estimates store b_m3, title(OLS)
quietly estadd local fe "Yes"
quietly estadd scalar rsqadj = e(r2_a)
quietly estadd scalar Nobs = e(N)
quietly estadd ysumm, me

quietly: areg powerdom2011 pmgsyroad pop5001k pop1k pc01_vd_power_dom if statedummy2==1, absorb(statedistrict) cluster(pcmod01_state)
quietly: estimates store b_m4, title(OLS)
quietly estadd local fe "Yes"
quietly estadd scalar rsqadj = e(r2_a)
quietly estadd scalar Nobs = e(N)
quietly estadd ysumm, me

quietly: areg tsc_status_2011 pmgsyroad pop5001k pop1k if statedummy2==1, absorb(statedistrict) cluster(pcmod01_state)
quietly: estimates store b_m5, title(OLS)
quietly estadd local fe "Yes"
quietly estadd scalar rsqadj = e(r2_a)
quietly estadd scalar Nobs = e(N)
quietly estadd ysumm, me

quietly: areg phc2011 pmgsyroad pop5001k pop1k phc2001 if statedummy2==1, absorb(statedistrict) cluster(pcmod01_state)
quietly: estimates store b_m6, title(OLS)
quietly estadd local fe "Yes"
quietly estadd scalar rsqadj = e(r2_a)
quietly estadd scalar Nobs = e(N)
quietly estadd ysumm, me

quietly: areg postoffice2011 pmgsyroad pop5001k pop1k postoffice2001 if statedummy2==1, absorb(statedistrict) cluster(pcmod01_state)
quietly: estimates store b_m7, title(OLS)
quietly estadd local fe "Yes"
quietly estadd scalar rsqadj = e(r2_a)
quietly estadd scalar Nobs = e(N)
quietly estadd ysumm, me

quietly: areg commbank2011 pmgsyroad pop5001k pop1k commbank2001 if statedummy2==1, absorb(statedistrict) cluster(pcmod01_state)
quietly: estimates store b_m8, title(OLS)
quietly estadd local fe "Yes"
quietly estadd scalar rsqadj = e(r2_a)
quietly estadd scalar Nobs = e(N)
quietly estadd ysumm, me

quietly: areg bus2011 pmgsyroad if statedummy2==1 & pc01_vd_bs_fac==0, absorb(statedistrict) cluster(pcmod01_state)
quietly: estimates store b_m9, title(OLS)
quietly estadd local fe "Yes"
quietly estadd scalar rsqadj = e(r2_a)
quietly estadd scalar Nobs = e(N)
quietly estadd ysumm, me


*********************************************************************************

*cd "2_Tables/"

*E.4

*esttab a_m* using E4.tex, b(3) se(3) keep(*popvar*) varlabel(1.popvar "$100<$ pop $\leq250$" 2.popvar "$250<$ pop $<500$" 3.popvar "$500\leq$ pop $<1000$" 4.popvar "pop $\geq1000$") title("Population thresholds and provision of electricity, toilets and PMGSY") mtitles("Electricity" "Open-defecation" "PMGSY") label drop(0.popvar) nonotes addnote("\makecell[tl]{\textit{Notes:} The unit of analysis is a census 2001 village in the sample of states used in main specifications.\\Measures of electricity and sanitation are measured as \% households in the village with the particular\\facility, while PMGSY road is a dummy which is 1 for villages that have benefited from PMGSY (new\\road/ bridge/ upgrade) between 2001-2011. All regressions control for baseline Census 2001 variables:\\village population, percentage of sc/st, whether village has access to primary school, secondary school,\\senior secondary school, distance to town, water supply, primary health centre, commercial banking,\\telephone facility, communication facility. Each regression has a district fixed effect, state clustered\\standard errors, and constant that is not reported. * p $<$ 0.05, ** p $<$ 0.01, *** p $<$ 0.001}") booktabs replace


esttab a_m* using "2_Tables/E4.doc", b(3) se(3) keep(*popvar*) varlabel(1.popvar "100 < pop <= 250" 2.popvar "250 < pop < 500" 3.popvar "500 <= pop < 1000" 4.popvar "pop >= 1000") title("Population thresholds and provision of electricity, toilets and PMGSY") mtitles("Electricity" "Open-defecation" "PMGSY") label drop(0.popvar) nonotes addnote("Notes: The unit of analysis is a census 2001 village in the sample of states used in main specifications. Measures of electricity and sanitation are measured as % households in the village with the particular facility, while PMGSY road is a dummy which is 1 for villages that have benefited from PMGSY (new road/ bridge/ upgrade) between 2001-2011. All regressions control for baseline Census 2001 variables: village population, percentage of sc/st, whether village has access to primary school, secondary school, senior secondary school, distance to town, water supply, primary health centre, commercial banking, telephone facility, communication facility. Each regression has a district fixed effect, state clustered standard errors, and constant that is not reported. * p < 0.05, ** p < 0.01, *** p < 0.001}") rtf replace collabels(none)


*E.5

*esttab b_m* using E5.tex, b(3) se(3) keep(pmgsyroad) varlabel(pmgsyroad "PMGSY village") title("Impact of receiving PMGSY benefits on other public goods and services in 2011") mtitles("\makecell[c]{Primary\\schools}" "\makecell[c]{Sec\\schools}" "\makecell[c]{Sr. Sec\\schools}" "\makecell[c]{Domestic\\Electricity}" "\makecell[c]{Sanitation\\coverage}" "\makecell[c]{Primary health\\center}" "\makecell[c]{Post\\office}" "\makecell[c]{Commercial\\bank}" "\makecell[c]{Bus\\service}") label  nonotes addnote("\makecell[tl]{\textit{Notes:} Table reports robust OLS estimates. The unit of analysis is a census 2001 village in the sample of states used in main specifications. PMGSY village\\is a dummy that is 1 if the village has received any PMGSY benefit and 0 otherwise. Each dependent variable is from the Census 2011. All regressions are\\estimated on a subsample of villages where the particular service is unavailable at baseline. Standard errors are clustered at the state-level. Each regression\\has a district fixed effect, state clustered standard errors, and constant that is not reported. * p $<$ 0.05, ** p $<$ 0.01, *** p $<$ 0.001}") scalars("fe District FE" "Nobs N" "rsqadj Adj. $ R^2$" "ymean Mean") sfmt("%-20s" "%9.0f" "%9.3f" "%9.3f") noobs booktabs replace

esttab b_m* using "2_Tables/E5.doc", cells(b(star fmt(3)) se(par fmt(3))) keep(pmgsyroad) varlabel(pmgsyroad "PMGSY village") title("Impact of receiving PMGSY benefits on other public goods and services in 2011") mtitles("Primary schools" "Sec schools" "Sr. Sec schools" "Domestic Electricity" "Sanitation coverage" "Primary health Cntr" "Post office" "Commercial bank" "Bus service") label  nonotes addnote("Notes: Table reports robust OLS estimates. The unit of analysis is a census 2001 village in the sample of states used in main specifications. PMGSY village is a dummy that is 1 if the village has received any PMGSY benefit and 0 otherwise. Each dependent variable is from the Census 2011. All regressions are estimated on a subsample of villages where the particular service is unavailable at baseline. Standard errors are clustered at the state-level. Each regression has a district fixed effect, state clustered standard errors, and constant that is not reported. * p < 0.05, ** p < 0.01, *** p < 0.001}") scalars("fe District FE" "Nobs N" "rsqadj Adj. R^2" "ymean Mean") sfmt("%-20s" "%9.0f" "%9.3f" "%9.3f") noobs rtf collabels(none) replace varwidth(8) modelwidth(3 3 3 5 4 5 3 6 3) substitute("\fs20" "\fs16" "\fs24" "\fs20")
log close
